<?php

//select phone from uinfo where fen > 0 group by phone having count(phone) >1 ORDER BY `uinfo`.`phone` ASC
exit;
set_time_limit(0); 
include '../c/config.php';

$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);

$checkList=['13512148268','13162668675','13564481174','13601615048','13636303325','13661705079','13671761342',
'13681637122','13681817266','13774227142','13817627288','13901964270','13916861073','13918187994','13918300411','15902199977','15960397502','18017277119','18019097476','18221720816','18795503537'


];
$j=0;
$query=$mysqli->query("select phone from d3 WHERE id > 32550 group by phone having count(phone) >1 ");
while ($list=$query->fetch_array()) {
      $phone=$list['phone'];

      //echo $phone;
      //echo "<br />";
     
     $queryD=$mysqli->query("select * from d3 WHERE phone ='".$phone."' ");
     $i=1;
     $a=array();
     $b=array();
     while ($listD=$queryD->fetch_array()) {
          if (1 == $i) {
               $a=array('createtime'=>$listD['createtime'],'dui'=>$listD['dui'],'yi'=>$listD['yi'],'id'=>$listD['id'],'er'=>$listD['er'],'san'=>$listD['san'], 'uid'=>$listD['uid']);
           } 

           if (1 <  $i) {
               $b=array('createtime'=>$listD['createtime'],'dui'=>$listD['dui'],'yi'=>$listD['yi'],'id'=>$listD['id'],'er'=>$listD['er'],'san'=>$listD['san'], 'uid'=>$listD['uid']);
           }

        $i++;
     }


     if ($a['createtime'] == $b['createtime'] || $a['dui'] == $b['dui']) {
          if (!in_array($phone, $checkList)) {
                 echo "<br />";
               echo $j.'........yes...........',$phone;
               
               if ($a['yi'] == $b['yi'] && $a['er'] == $b['er'] && $a['san'] == $b['san'] && $a['uid'] == $b['uid']) {
                     echo "........",$b['id'];
                     echo "<br />";
                     $sql="update d3 set uid='".$a['uid']."-del', phone='".$phone."-del' where id='".$b['id']."' ";
                     echo $sql;
                     if($i < 4){
                         $mysqli->query($sql);
                     } 
                     echo "<br /><br />";

               }

               echo "<br />";


               $j++;
          }
          
     }
     
      //SELECT * FROM `d3` WHERE `phone` LIKE '12482633906'


}